package io.bluerain.g4_tools.entities;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by foredawn on 15-9-14.
 * 索引配置对象
 */
public class Index {

    //版本
    private String version;
    //机型
    private String model;
    //说明
    private String info;
    //资源列表
    private List<ResourceInfo> resources = new ArrayList<>();
    //挂载分区列表
    private List<String> mounts = new ArrayList<>();
    //工具版本
    private String toolVersion;

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public List<ResourceInfo> getResources() {
        return resources;
    }

    public void setResources(List<ResourceInfo> resources) {
        this.resources = resources;
    }

    public String getToolVersion() {
        return toolVersion;
    }

    public void setToolVersion(String toolVersion) {
        this.toolVersion = toolVersion;
    }

    public List<String> getMounts() {
        if (mounts == null)
            mounts = new ArrayList<>();
        List<String> tempMounts = new ArrayList<>();
        for (String mount : mounts) {
            tempMounts.add("mount -o remount rw " + mount);
        }
        return tempMounts;
    }

    public void setMounts(List<String> mounts) {
        this.mounts = mounts;
    }

    /**
     * 添加一个资源
     *
     * @param resource 资源对象
     */
    public void addResource(ResourceInfo resource) {
        this.getResources().add(resource);
    }

    @Override
    public String toString() {
        return "Index{" +
                "version='" + version + '\'' +
                ", model='" + model + '\'' +
                ", info='" + info + '\'' +
                ", resources=" + resources +
                ", mounts=" + mounts +
                ", toolVersion='" + toolVersion + '\'' +
                '}';
    }
}
